﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using WPExtensions;

namespace WPExtensionsDemo
{
    public partial class AdvancedApplicationBarDemo : PhoneApplicationPage
    {
        public AdvancedApplicationBarDemo()
        {
            InitializeComponent();
        }

        private ViewModelDemo viewModel
        {
            get
            {
                return this.DataContext as ViewModelDemo;
            }
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            viewModel.AppBarIconButtonEnabled =
                !viewModel.AppBarIconButtonEnabled;
        }

        private void ButtonVisibility_Click(object sender, RoutedEventArgs e)
        {
            
            viewModel.Visibility = 
                viewModel.Visibility == Visibility.Visible ? 
                Visibility.Collapsed : Visibility.Visible;
            
        }

        private void ButtonChangeText_Click(object sender, RoutedEventArgs e)
        {
            viewModel.AppBarIconButtonText += " 1";
        }

        readonly Uri iconUri1 = new Uri("/Images/appbar.add.rest.png", UriKind.Relative);
        readonly Uri iconUri2 = new Uri("/Images/appbar.save.rest.png",UriKind.Relative);

        private bool viewIcon = false;

        private void ButtonChangeIcon_Click(object sender, RoutedEventArgs e)
        {
            viewModel.IconUri = viewIcon ? iconUri1 : iconUri2;

            viewIcon = !viewIcon;

        }

        private void AdvancedApplicationBarIconButton_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Click event");
        }
    }

    public class MyPage : FrameworkElement
    {
        private ApplicationBar appBar;
        public ApplicationBar AppBar
        {
            get { return appBar; }
            set
            {
                
                
                appBar = value;

            }
        }
    }
}